ee549b8865f216960942669d6c698ba378b3cd7e,src/org/exist/http/RESTServer.java,RESTServer,writeResourceAs,#DocumentImpl#DBBroker#String#String#String#Properties#HttpServletRequest#HttpServletResponse#,1191

Before Change



				response.setContentType(asMimeType);
			} else {
				response.setContentType(resource.getMetadata().getMimeType());
			}
			OutputStream os = response.getOutputStream();
			broker.readBinaryResource((BinaryDocument) resource, os);

After Change


	// null uses the type of the resource
	private void writeResourceAs(DocumentImpl resource, DBBroker broker,
			String stylesheet, String encoding, String asMimeType,
			Properties outputProperties, HttpServletRequest request, HttpServletResponse response)
			throws BadRequestException, PermissionDeniedException, IOException {

		// Do we have permission to read the resource
		if (!resource.getPermissions().validate(broker.getUser(),
				Permission.READ)) {
			throw new PermissionDeniedException("Not allowed to read resource");
		}

		if (resource.getResourceType() == DocumentImpl.BINARY_FILE) {
			// binary resource

			if (asMimeType == null) { // wasn't a mime-type specified?
				asMimeType = resource.getMetadata().getMimeType();
			}
			
			if (asMimeType.startsWith("text/")){
				response.setContentType(asMimeType + "; charset="
						+ encoding);
			} else {
				response.setContentType(asMimeType);
			}